<!DOCTYPE html>
<html>
<head>
{{template "inc/meta.tpl" .}}
</head>
<body>
{{template "inc/user-info.tpl" .}}
<!-- 顶部 -->
<div id="middle">
{{template "inc/left.tpl" .}}
    <div class="Switch"></div>
    <div class="right"  id="mainFrame">
        <div class="right_cont">
            <ul class="breadcrumb">当前位置：
                <a href="#">首页</a> <span class="divider">/</span>
                <a href="#">用户中心</a> <span class="divider">/</span>
                登录记录
            </ul>
            <div class="title_right"><strong>登录记录</strong></div>
            <div style="width:900px; margin:auto">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <td width="10%" align="right" nowrap="nowrap" bgcolor="#f1f1f1">款到开始时间：</td>
                        <td width="23%"><input type="text" class="laydate-icon span1-1" id="Calendar" value="2015-08-25" /></td>
                        <td width="10%" align="right" nowrap="nowrap" bgcolor="#f1f1f1">款到结束时间：</td>
                        <td width="23%"><input type="text" class="laydate-icon  span1-1" id="Calendar2" value="2015-08-25" /></td>
                        <td width="10%" align="right" nowrap="nowrap" bgcolor="#f1f1f1">选择排行内容：</td>
                        <td><input type="text" class=" span1-1" /></td>
                    </tr>
                    </tbody>
                </table>
                <table class="margin-bottom-20 table  no-border">
                    <tbody>
                    <tr>
                        <td class="text-center"><input id="query_info" type="button" value="查询" class="btn btn-info " style="width:80px;" /></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered table-hover table-striped">
                    <thead>
                    <tr align="center">
                        <td><strong>编号</strong></td>
                        <td><strong>来源编码</strong></td>
                        <td><strong>AppKey</strong></td>
                        <td><strong>目标路径</strong></td>
                        <td><strong>登录IP地址</strong></td>
                        <td><strong>登录时间</strong></td>
                    </tr>
                    </thead>
                    <tbody id="infolist">
                    </tbody>
                </table>
                <table class="margin-bottom-20 table  no-border">
                    <tbody>
                    <tr>
                        <td class="text-center"><input type="button" value="打印" class="btn btn-info    margin-right-20" style="width:80px;" /><input type="button" value="数据导出" class="btn btn-info  " style="width:80px;" /></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{{template "inc/foot.tpl" .}}
<script type="text/javascript">
    var _page_size=10;
    var myMenu;
    window.onload = function() {
        myMenu = new SDMenu("my_menu");
        myMenu.init();
    };
    $(function () {
        querylist(1);
    });
    String.prototype.format = function(){
        var args = arguments;
        return this.replace(/\{(\d+)\}/g,
                function(m,i){
                    return args[i];
                });
    }
    function querylist(_page_index) {
        var d=dialog({
            title:"查询中，请稍候……",
            width:'360',
            height:'180',
        });
        $.ajax({
            url: '/users/logininfo',
            type: 'POST',
            async: true,
            data: {
                page_index: _page_index,
                page_size: _page_size
            },
            timeout: 10000,
            dataType: 'json',
            beforeSend: function (xhr) {
                d.showModal();
                $("#infolist").children('tr').remove();
            },
            success: function (data, textStatus, jqXHR) {
                if(data.code==0){
                    alert_it("结果","code:"+data.code+",msg:"+data.message);
                }else{
                    $.each(data.message, function(){
                        $("#infolist").append("<tr align=\"center\"><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>".format(this.LogId,this.SourceId,this.AppKey,this.BuildPath,this.IP,timestampToTime(this.LoginTime)))
                    });
                }
            },
            error: function (xhr, textStatus) {
                alert_it("错误",textStatus);
            },
            complete: function () {
                d.close();
                $("#email").val("");
                $("#password").val("");
            }
        });
    }
    $(function () {
        $("#query_info").click(function () {
            querylist(1);
        });
    });
    function timestampToTime(timestamp) {
        var date = new Date(timestamp*1000);
        var Y = date.getFullYear() + '-';
        var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
        var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
        var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
        var s = (date.getSeconds() <10 ? '0' + date.getSeconds() : date.getSeconds());
        return Y+M+D+h+m+s;
    }
</script>
</body>
</html>